<!--ljx 2022.9.1 测试页面  -->
<template>
    <div class=''>
			<el-row :gutter="20">
				   <el-col :span="2"/>
			  <el-col :span="5" >
					<!-- <div style="background-color: green;min-height: 400px;width: 100%;display: block;height: 100%;">
						<div><img src="/public/left2.png" /> </div>
						<div style="display: inline-block;text-align: center;">

							<div style="display: flex;"><div	class="demo-radius">苹果</div><div	class="demo-radius">沃柑</div></div>
							<div style="display: flex;"><div	class="demo-radius">芒果</div><div	class="demo-radius">香蕉</div></div>
							<div style="display: flex;"><div	class="demo-radius">桃子</div><div	class="demo-radius">樱桃</div></div>
							<div style="display: flex;"><div	class="demo-radius">椰子</div><div	class="demo-radius">龙眼</div></div>

						</div>
					</div> -->
					<myleft></myleft>
				</el-col>
			  <el-col :span="15" style="margin-left: -14px;">
					  <el-breadcrumb  style="background-color:orange;color: white;height: 34px;font-size: 20px;padding-left: 20px;padding-top: 10px;">
					    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
					    <el-breadcrumb-item  :to="{ path: '/' }">{{listname}}</el-breadcrumb-item>
					    <el-breadcrumb-item>promotion list</el-breadcrumb-item>
					  </el-breadcrumb>
					<div style="display: flex;flex-wrap: wrap;">
					  <el-card  shadow="hover" :body-style="{ padding: '4px' }" v-for="(item, index) in myGoodsList"   style="width: 246px;height: 270px;margin-left: 10px;margin-top: 10px">
						<router-link :to="{name:'indexcontent',query:{id:item.id}}"><img :src="item.img" style="width: 90%;"/></router-link>

						<div style="padding: 4px">
						  <span>{{item.title}}</span>
						  <div style="color: red;padding-top: 4px;">
							¥{{item.price}}
						  </div>
						</div>
					  </el-card>
					</div>
				</el-col>
				 <el-col :span="2"/>
			</el-row>
    </div>
</template>

<script>
    //这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
    //例如：import 《组件名称》 from '《组件路径》';
	import myleft from '../components/myleft.vue'
    export default {
        data() {
            //这里存放数据
            return {
                msg: '测试数据',
				listname:'苹果列表',
				myGoodsList:[],
            };
        },
        //import引入的组件需要注入到对象中才能使用
        components: {
			myleft
        },
        //监听属性 类似于data概念
        computed: {},
        //监控data中的数据变化
        watch: {},
        //方法集合
        methods: {
            frun() {
                alert('我是老大');
            },
			mygetdata() {
				// console.log(11)
				let myparams = {
					goodtype: this.$route.query.goodtype
				};
				console.log('myparams:', myparams);
				this.getdata('/system/goodtable/list?pageNum=1&pageSize=22', myparams).then(response => {
					this.myGoodsList.splice(0,this.myGoodsList.length);//清空数组

					for (var index in response.rows) {
						let newgood = {
							id: response.rows[index],
							img: "/a1.jpg",
							title: "测试",
							describe: "新产品",
							price: 121,
							num: 3,
							memo: '无'
						};

						response.rows[index].img = 'http://localhost/dev-api' + response.rows[index].img;
						newgood.id = response.rows[index].id;
						newgood.img = response.rows[index].img;
						newgood.title = response.rows[index].title;
						newgood.describe = response.rows[index].mydescribe;
						newgood.price = response.rows[index].price;
						newgood.num = response.rows[index].num;
						newgood.memo = response.rows[index].memo;
						this.myGoodsList.push(newgood);
					}

				}).catch((err) => {
					console.log('err')
				})
			},
        },
        //生命周期 - 创建完成（可以访问当前this实例）
        created() {

        },
        //生命周期 - 挂载完成（可以访问DOM元素）
        mounted() {

			this.mygetdata();
        },
		//如果使用updated,系统会陷入死循环，所以改为用监测变量的方式。
		watch: {
			listname: async function() {
				this.mygetdata();
			}
		},
        beforeCreate() { }, //生命周期 - 创建之前
        beforeMount() { }, //生命周期 - 挂载之前
        beforeUpdate() { }, //生命周期 - 更新之前
        updated() {
			this.listname = this.$route.query.goodtype;
		}, //生命周期 - 更新之后
        beforeDestroy() { }, //生命周期 - 销毁之前
        destroyed() { }, //生命周期 - 销毁完成
        activated() {
			this.mygetdata();
		}, //如果页面有keep-alive缓存功能，这个函数会触发
    }
</script>
<style scoped>

</style>
